package com.lej.app_main.ext

import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator

fun View.visibleAnimation(linearInterpolator: LinearInterpolator) {
    animate().setInterpolator(linearInterpolator)
        .setDuration(200)
        .translationY(0f)
}

fun View.goneAnimation(linearInterpolator: LinearInterpolator) {
    val distance = (this.height + this.getMarginBottom()).toFloat()
    animate().setInterpolator(linearInterpolator)
        .setDuration(200)
        .translationY(distance)
}

fun View.getMarginBottom() =
    (layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 0